package com.dddd.blog.blogcommon.utils;


import com.dddd.blog.blogcommon.constant.ResultCode;
import com.dddd.blog.blogcommon.pojo.Result;

/**
 * @author 喵星球的大橘
 * 统一响应工具类
 */
@SuppressWarnings("all")
public class ResultUtils{

    /**
     * @return result
     * 响应请求成功
     */
    public static Result success(){

        return new Result().setResult(ResultCode.SUCCESS);
    }

    /**
     * @return result
     * @param data 响应体
     * 响应请求并返回数据
     */
    public static Result success(Object data){

        return new Result().setResult(ResultCode.SUCCESS,data);
    }

    /**
     * @return result
     * 响应请求失败
     */
    public static Result error(ResultCode resultCode){

        return new Result().setResult(resultCode);
    }

    /**
     * @return result
     * @param data 响应体
     * 响应请求失败并返回数据
     */
    public static Result error(ResultCode resultCode, Object data){

        return new Result().setResult(resultCode, data);
    }
}